/*
 * Project: BoboDesignPattern
 * 
 * File Created at 2019年4月17日
 * 
 * Copyright 2012 Greenline.com Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Greenline Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Greenline.com.
 */
package test.lesson3.tree.binarytree;

/**
 * @Type ArrayBinaryTree
 * @Desc
 * @author 52489
 * @date 2019年4月17日
 * @Version V1.0
 */
public class ArrayBinaryTree {

    int[] data;

    /**
     * @param data
     */
    public ArrayBinaryTree(int[] data) {
        this.data = data;
    }

    public void frontShow() {
        frontShow(0);
    }

    public void frontShow(int index) {
        if (data == null || data.length == 0) {
            return;
        }
        System.out.println(data[index]);

        // 处理左子树
        if (2 * index + 1 < data.length) {
            frontShow(2 * index + 1);

        }

        // 处理右子树
        if (2 * index + 2 < data.length) {
            frontShow(2 * index + 2);

        }
    }

}
